package com.hykj.coca.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hykj.coca.config.Config;
import com.hykj.coca.mapper.MeassgeMapper;
import com.hykj.coca.model.MeassgeModel;
import org.springframework.stereotype.Service;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class MeassgeService extends BaseService<MeassgeModel,MeassgeMapper>{

    DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");

    public  Integer getUnReadCount(Map condation){
        return mapper.getUnReadCount(condation);
    }

    @Override
    public MeassgeModel change(MeassgeModel model, Map condition) {
        if (condition.get("change")!=null) {
            MeassgeModel meassgeModel = new MeassgeModel();
            meassgeModel.setMsgId(model.getId());
            meassgeModel.setMsgTitle(model.getTitle());
            meassgeModel.setIsRead(model.getIs_read());
            meassgeModel.setMsgContent(model.getMeassge_content());
            String createTime = dateFormat.format(model.getCreate_time());
            meassgeModel.setCreateTime(createTime);
            meassgeModel.setMsgJumpUrl(model.getMsg_url());
            return meassgeModel;
        }else
            return super.change(model,condition);
    }
}
